package com.Calculator.view.Button.impl;


import com.Calculator.models.impl.FunsName;
import com.Calculator.models.impl.Theme;
import com.Calculator.view.Button.iMyJButton;
import javax.swing.*;
import java.awt.*;

public class FunsButton implements iMyJButton{
    private JButton[] funs;

    public FunsButton(Theme theme) {
        //获取fun名字对象
        FunsName funsName = new FunsName();
        //fun按钮对象数组
        this.funs = new JButton[funsName.getLength()];

        //初始化funs按钮
        for(int i = 0; i < funs.length; i++) {
            this.funs[i] = new JButton(funsName.getName()[i]);
            this.funs[i].setPreferredSize(new Dimension(60,130));
            this.funs[i].setFont(theme.getFont());
            this.funs[i].setBackground(theme.getButtonColor());
            this.funs[i].setBorder(BorderFactory.createRaisedBevelBorder());
        }
    }

    public JPanel setPanel() {
        JPanel funsPanel = new JPanel(new GridLayout(4,1,30,30));
        funsPanel.setBorder(BorderFactory.createEmptyBorder(30, 3, 30, 30));
        for (JButton fun : funs) {
            funsPanel.add(fun);
        }
        return funsPanel;
    }

    @Override
    public JButton[] getButton() {
        return funs;
    }

    @Override
    public void setButton(JButton[] button) {
        this.funs = button;
    }
}
